home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C023A.ZIP / PART2 / PLOT.ASM < prev    next >
Assembly Source File  |  1990-01-31  |  2KB  |  138 lines

  1. ;
  2. ; RSX to set/test bit in screen memory
  3. ;  H contains action byte:  0  set bit
  4. ;                           1  clear bit
  5. ;                           2  toggle bit
  6. ;                            3  fetch bit
  7. ;                            4  fetch byte
  8. ;  L contains y coordinate (0 <=  L <= 255 )
  9. ; DE contains x coordinate (0 <= DE <= 719 )
  10. ;
  11. ; The plot RSX is built using the sequence of commands:
  12. ;
  13. ;    rmac plot
  14. ;    link plot[op
  15. ;    era plot.rsx
  16. ;    ren plot.rsx=plot.prl
  17. ;
  18. ;
  19. ;
  20. wboot:    equ    1
  21. scrrun:    equ    000e9h
  22. ;
  23.     cseg
  24.     db    0,0,0,0,0,0
  25.     jmp    start
  26. next:    db    0c3h
  27.     dw    0
  28. prev:    dw    0
  29. remov:    db    0ffh
  30. nbank:    db    0
  31.     db    'SCRSETXY'
  32. loader:    db    0
  33.     db    0,0
  34. start:
  35.     mov    a,c
  36.     cpi    76
  37.     jz    begin
  38.     jmp    next
  39. begin:
  40.     push    h
  41.     lhld    wboot    ;form firmware exec address
  42.     lxi    b,87
  43.     dad    b
  44.     shld    cjfirm
  45.     pop    h
  46.     lxi    b,code
  47.     call    entfw
  48.     dw    scrrun
  49.     ret
  50. ;
  51. code:            ;perform operation in screen memory
  52.     mvi    a,3    ;restrict range of x to 0..1023
  53.     ana    d
  54.     mov    d,a
  55.     push    h    ;save action byte
  56.     mvi    h,0    ;restrict range of y to 0..255
  57.     dad    h    ;fetch roll table pointer
  58.     lxi    b,0b600h
  59.     dad    b
  60.     mov    c,m    ;get address from table
  61.     inx    h
  62.     mov    b,m    ;BC contains pixel row pointer
  63. ;
  64.     mov    a,c    ;mask off low order bits of pointer
  65.     ani    0f8h
  66.     mov    l,a
  67.     mov    h,b    ;put it in HL
  68.     dad    h    ;shift masked pointer left
  69.     dad    d    ;add x to masked pointer
  70.     mov    a,l    ;mask off low order bits from x
  71.     ani    0f8h
  72.     mov    l,a
  73. ;
  74.     mov    a,c    ;get low order bits of pixel row pointer
  75.     ani    7
  76.     ora    l    ;add low order bits into HL
  77.     mov    l,a    ;HL now contains memory address of bit
  78. ;
  79.     mov    a,e    ;get low order bits of x
  80.     ani    7
  81.     inr    a
  82.     mov    b,a    ;B contains rotate count
  83. ;
  84.     xra    a    ;clear A
  85.     stc        ;set carry bit
  86. loop:    rar        ;form mask by shifting carry
  87.     db    010h    ;djnz loop
  88.     db    0fdh    ;(not available in this assembler)
  89. ;
  90.             ;mask in A, address in HL
  91. ;
  92.     pop    b    ;fetch action byte
  93.     mov    c,a    ;save mask in C
  94.     mov    a,b
  95.     cpi    0    ;check action byte
  96.     jnz    not0
  97.     mov    a,c    ;action byte = 0
  98.     ora    m    ;set bit in memory
  99.     mov    m,a
  100.     ret
  101. ;
  102. not0:
  103.     cpi    1
  104.     jnz    not1
  105.     mov    a,c    ;action byte = 1
  106.     cma        ;clear bit in memory
  107.     ana    m
  108.     mov    m,a
  109.     ret
  110. ;
  111. not1:
  112.     cpi    2
  113.     jnz not2
  114.     mov    a,c    ;action byte = 2
  115.     xra    m    ;toggle bit in memory
  116.     mov    m,a
  117.     ret
  118. ;
  119. not2:
  120.     cpi 3
  121.     jnz not3
  122.     mov a,c    ;action byte = 3
  123.     ana m    ;test bit in memory
  124.     mov l,a
  125.     mvi h,0
  126.     ret
  127. ;
  128. not3:
  129.     cpi 4
  130.     rnz        ;unknown action, return
  131.     mov l,m    ;action byte = 4
  132.     mvi h,0    ;return byte from screen memory
  133.     ret
  134. ;
  135. entfw:    db    0c3h
  136. cjfirm:    dw    0
  137.     end
  138.